public class bibtwork2 {
    // 力扣110. 平衡二叉树
    public boolean isBalanced(TreeNode root) {
        if(root==null){
            return true;
        }
        int ret=Math.abs(hightTree(root.left)-hightTree(root.right));
        if(ret>1){
            return false;
        }
        return isBalanced(root.left)&&isBalanced(root.right);
    }
    public int hightTree(TreeNode root){
        if(root==null){
            return 0;
        }
        int hleft=hightTree(root.left);
        int hright=hightTree(root.right);
        return Math.max(hleft,hright)+1;
    }
}
